{include file='public/header' /}
    <style>
        .layui-form-label{width: 140px}
        .layui-input-inline{}
        .header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
        .header div{border-bottom: solid 2px #009688;margin: 8px 0 6px 0;}
        .header button{float: right;margin-top: -5px;}
    </style>
</head>
<body style="padding: 10px;">
<div class="header">
    <span>添加商圈</span>
    <div></div>
</div>
<form class="layui-form" lay-filter="form">





    <div class="layui-form-item">
        <label class="layui-form-label">选择地区</label>
        <div class="layui-input-inline">
            <select name="provid" id="provid" lay-filter="provid" value=""  lay-verify="required">
                {$s_html|raw}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择地区</label>
        <div class="layui-input-inline">
            <select name="cityid" id="cityid" lay-filter="cityid" value=""  lay-verify="required">
                <option value="">请选择市</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择地区</label>
        <div class="layui-input-inline">
            <select name="bc_area_id" id="bc_area_id" lay-filter="bc_area_id" value=""  lay-verify="required">
                <option value="">请选择县/区</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: #FF5722">*</span>商圈名称</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="bc_name" lay-verify="required">
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="save" class="layui-btn" lay-submit lay-filter="save">保存</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    layui.use(['layer','form','upload'],function(){
        form = layui.form;
        layer = layui.layer;
        $ = layui.jquery;
        upload = layui.upload;
        form.on('submit(save)', function(data){
            $.post('__PUBLIC__/admin/BusinessCircle/save',$('form').serialize(),function(res){
                //console.log(res);
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else{
                    layer.msg(res.msg);
                    // layer.msg('文字保存成功，正在提交图片请稍候。。。', {icon: 16,time: 100000,shade : [0.5 , '#000' , true]});
                    // var d1 = document.getElementById('upup');
                    // d1.click();
                    //setTimeout(function(){parent.window.location.reload();},1000);
                    //setTimeout(function(){window.location.reload();},1000);
                }
            },'json');return false;
        });
        form.on('select(provid)', function(data){
            console.log(data.elem.value);
            if (data.elem.value == undefined||data.elem.value == null||data.elem.value == "") {
                $("select[name=cityid]").empty();
                $("select[name=bc_area_id]").empty();
                form.render();
                return;
            }
            $.post('__PUBLIC__/admin/BusinessCircle/shi',{'p1':data.elem.value},function (res){
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else {
                    layer.msg(res.msg,{icon:1,time:1100});
                    $("select[name=cityid]").empty();
                    $("select[name=bc_area_id]").empty();
                    $("select[name=cityid]").append(res.data);

                    form.render();    //刷新select选择框渲染
                }
            },'json');
        });
        form.on('select(cityid)', function(data){
            console.log(data);
            if (data.elem.value == undefined||data.elem.value == null||data.elem.value == "") {
                $("select[name=bc_area_id]").empty();
                form.render();
                return;
            }
            $.post('__PUBLIC__/admin/BusinessCircle/qu',{'p2':data.elem.value},function (res){
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else {
                    layer.msg(res.msg,{icon:1,time:1100});
                    $("select[name=bc_area_id]").empty();
                    $("select[name=bc_area_id]").append(res.data);
                    form.render();    //刷新select选择框渲染
                }
            },'json');
        });
        form.val("form", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值'con_house_nature' => string '1' (length=1)
            'con_house_cqzslb':''
            // ,'provid' :  '420000'
            // ,'cityid' :  '420100'
            // ,'areaid' :  '420115'
        });
        form.verify({
            con_house_nature: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '用户名不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '用户名首尾不能出现下划线\'_\'';
                }
                if(/^\d+\d+\d$/.test(value)){
                    return '用户名不能全为数字';
                }
            }
            ,con_house_cqzm:[/\S/,'请填写商圈名称']
            //我们既支持上述函数式的方式，也支持下述数组的形式
            //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
            ,pass: [/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格']

        });
    });


    // window.setInterval("ssave()",10000);//每隔1秒，调用一次getDateDemo()
    // function ssave(){
    //     console.log(navigator);
    // }
</script>
</body>
</html>